import { createApp, type App as AppInstance } from "vue";
import App from "./App.vue";
import "./style.css";
import { renderWithQiankun, qiankunWindow } from "vite-plugin-qiankun/dist/helper";
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import './theme.css'

let app: AppInstance | null = null;
function render(props: any = {}) {
  const { container } = props;
  app = createApp(App);
  app.use(ElementPlus)
  app.mount(container ? container.querySelector("#app") : "#app");
}

if (!qiankunWindow.__POWERED_BY_QIANKUN__) {
  render();
}

renderWithQiankun({
  mount(props) {
    render(props);
  },
  bootstrap() {
    // console.log("bootstrap");
  },
  unmount(_props) {
    app?.unmount();
    app!._container.innerHTML = "";
    app = null;
  },
  update() {
    // console.log("update");
  },
});
